Skip to content

blog: one flag, every chunk — debug logging for TanStack AI#849

Merged
tannerlinsley merged 2 commits intoTanStack:mainfrom
AlemTuzlak:blog/debug-logging-tanstack-ai
Apr 22, 2026
Merged

blog: one flag, every chunk — debug logging for TanStack AI#849
tannerlinsley merged 2 commits intoTanStack:mainfrom
AlemTuzlak:blog/debug-logging-tanstack-ai

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

@AlemTuzlak AlemTuzlak commented Apr 22, 2026

Summary

Adds a new blog post announcing the pluggable, category-toggleable debug logging system that just shipped in @tanstack/ai (TanStack/ai#467).

Post angle is the "anti-platform" story: one flag, zero infra, pipes into whatever logger you already have. It walks through:

  • Turning it on with debug: true
  • The eight category toggles and why they're not a log level
  • Piping into a custom Logger (pino example)
  • The try/catch guarantee around user loggers
  • The small design calls behind emoji prefixes and console.dir({ depth: null })

Files

  • src/blog/debug-logging-for-tanstack-ai.md — the post
  • public/blog-assets/debug-logging-for-tanstack-ai/header.png — header image

Test plan

  • Preview renders correctly on the blog index
  • Header image loads
  • Outbound link to the docs guide (/ai/latest/docs/advanced/debug-logging) resolves

Summary by CodeRabbit

  • Documentation
    • New blog post documenting built-in debug logging for TanStack AI activities. Learn how to enable debugging via the debug option, explore eight toggleable logging categories, and understand console and custom logger output options.

Announce the new pluggable, category-toggleable debug logging system
that ships with @tanstack/ai. Covers the one-flag default, the eight
category toggles, piping into a custom Logger (pino etc.), the
try/catch guarantee around user loggers, and the design calls behind
emoji prefixes + console.dir(depth:null).
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2026

👷 Deploy request for tanstack pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 43bd7bd

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

A new blog post is added documenting debug logging capabilities for TanStack AI. The post covers enabling debug logging via configuration options across multiple activities (chat(), summarize, generateImage, etc.), categorizing output into eight independently toggleable categories, and detailing logger integration and error handling behavior.

Changes

Cohort / File(s) Summary
Blog Documentation
src/blog/debug-logging-for-tanstack-ai.md
New blog post introducing and documenting debug logging features, including configuration options, category toggles (request, provider, output, middleware, tools, agentLoop, config, errors), logger integration, and output formatting.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A logger arrives, all tagged and bright,
With emoji prefixes shining in sight!
Eight categories dance, toggled with care,
Debug logging magic floating through air! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change—adding a blog post about debug logging for TanStack AI with a focus on its single-flag, category-based approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/blog/debug-logging-for-tanstack-ai.md`:
- Line 13: Add a comma after the introductory phrase "Up until now" in the
sentence that begins "Up until now your options were limited." so it reads "Up
until now, your options were limited."—locate the sentence in the content block
(the line starting with "Up until now your options were limited.") and insert
the comma immediately after "now".
- Around line 35-42: The fenced code block showing the console output (the block
starting with the lines like "📤 [tanstack-ai:request] ..." and "🔧
[tanstack-ai:tools] ...") lacks a language specifier; update the opening fence
from ``` to a language such as ```text or ```console so the snippet
renders/accessibility is improved (e.g., change the opening fence to "```text"
while leaving the block contents unchanged).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a5e08e5-f683-44e6-b8aa-0038385e9995

📥 Commits

Reviewing files that changed from the base of the PR and between eb49d0e and 43bd7bd.

⛔ Files ignored due to path filters (1)
  • public/blog-assets/debug-logging-for-tanstack-ai/header.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • src/blog/debug-logging-for-tanstack-ai.md


You kick off a `chat()` call. A chunk goes missing. A middleware you wrote last week doesn't seem to fire. A tool gets called with arguments you can't explain. Your stream finishes, the UI looks wrong, and you have no idea which layer lied to you.

Up until now your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add comma after introductory phrase.

The sentence should read: "Up until now**,** your options were limited."

📝 Proposed fix
-Up until now your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.
+Up until now, your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Up until now your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.
Up until now, your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/blog/debug-logging-for-tanstack-ai.md` at line 13, Add a comma after the
introductory phrase "Up until now" in the sentence that begins "Up until now
your options were limited." so it reads "Up until now, your options were
limited."—locate the sentence in the content block (the line starting with "Up
until now your options were limited.") and insert the comma immediately after
"now".

Comment on lines +35 to +42
```
📤 [tanstack-ai:request] 📤 activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true
🔁 [tanstack-ai:agentLoop] 🔁 run started
📥 [tanstack-ai:provider] 📥 provider=openai type=response.output_text.delta
📨 [tanstack-ai:output] 📨 type=TEXT_MESSAGE_CONTENT
🧩 [tanstack-ai:middleware] 🧩 hook=onOutput
🔧 [tanstack-ai:tools] 🔧 tool=getTodos phase=before
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add language specifier to fenced code block.

The console output example should specify a language (e.g., text or console) for proper rendering and accessibility.

📝 Proposed fix
-```
+```text
 📤 [tanstack-ai:request] 📤 activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true
 🔁 [tanstack-ai:agentLoop] 🔁 run started
 📥 [tanstack-ai:provider] 📥 provider=openai type=response.output_text.delta
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
📤 [tanstack-ai:request] 📤 activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true
🔁 [tanstack-ai:agentLoop] 🔁 run started
📥 [tanstack-ai:provider] 📥 provider=openai type=response.output_text.delta
📨 [tanstack-ai:output] 📨 type=TEXT_MESSAGE_CONTENT
🧩 [tanstack-ai:middleware] 🧩 hook=onOutput
🔧 [tanstack-ai:tools] 🔧 tool=getTodos phase=before
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)

[warning] 35-35: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/blog/debug-logging-for-tanstack-ai.md` around lines 35 - 42, The fenced
code block showing the console output (the block starting with the lines like
"📤 [tanstack-ai:request] ..." and "🔧 [tanstack-ai:tools] ...") lacks a
language specifier; update the opening fence from ``` to a language such as
```text or ```console so the snippet renders/accessibility is improved (e.g.,
change the opening fence to "```text" while leaving the block contents
unchanged).

@tannerlinsley tannerlinsley merged commit 454493e into TanStack:main Apr 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants